package bishi.lixiang;

/**
 * @author: Tangxz
 * @email: 1171702529@qq.com
 * @cate: 2022/03/02 23:38
 */
// 本题为考试单行多行输入输出规范示例，无需提交，不计分。

import java.util.*;

public class _1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int[] nums = new int[n+1];
        Map<Integer, List<Integer>> map = new HashMap<>();
        while(m>0){
            m--;
            int a = in.nextInt();
            int b = in.nextInt();
            if (map.containsKey(a)){
                map.get(a).add(b);
            }else {
                map.put(a,new ArrayList<Integer>(){{add(b);}});
            }
            nums[a]++;
        }
        int res = 0;
        boolean[] bs = new boolean[n+1];
        for (int i=1;i<=n;i++){
            if (map.containsKey(i)&&!bs[i]){
                int now = dfs(map,nums,bs,i);
                nums[i] = now;
                res = Math.max(res,nums[i]);
            }
        }
        System.out.println(res);
    }
    public static int dfs(Map<Integer, List<Integer>> map,int[] nums,boolean[] bs,int nowI){
        if (!map.containsKey(nowI)){
            bs[nowI] = true;
            return 0;
        }
        bs[nowI] = true;
        List<Integer> list = map.get(nowI);
        int now = 0;
        for (int i:list){
            if (bs[i]){
                now+=nums[i]-1;
                continue;
            }
            if (map.containsKey(i)){
                now+= dfs(map,nums,bs,i)-1;
            }
        }
        return list.size()+now;
    }
}